//
//  DeviceInfo.m
//  FishTank
//
//  Created by Scott Zhu on 14/11/25.
//  Copyright (c) 2014年 Scott Zhu. All rights reserved.
//

#import "DeviceInfo.h"

@implementation DeviceInfo

-(id)initWithDid:(NSString *)did
      macAddress:(NSString *)macAddress
        password:(NSString *)password
              ip:(NSString *)ip
          isLock:(BOOL)isLock
{
    self = [super init];
    if (self)
    {
        self.did = did;
        self.macAddress = macAddress;
        self.password = password;
        self.ip = ip;
        self.isLock = isLock;
        self.name = @"新设备";
        self.is_temperature_on = NO;
        self.is_load_on = NO;
        self.is_level_on = NO;
    }
    return self;
}

-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.did forKey:@"did"];
    [aCoder encodeObject:self.macAddress forKey:@"macAddress"];
    [aCoder encodeObject:self.password forKey:@"password"];
    [aCoder encodeObject:self.ip forKey:@"ip"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeBool:self.isLock forKey:@"isLock"];
    [aCoder encodeObject:self.ID forKey:@"id"];
    [aCoder encodeBool:self.is_temperature_on forKey:@"is_temperature_on"];
    [aCoder encodeBool:self.is_level_on forKey:@"is_level_on"];
    [aCoder encodeBool:self.is_load_on forKey:@"is_load_on"];
    [aCoder encodeInteger:self.loadSubsribeID forKey:@"load_subscribe_id"];
    [aCoder encodeInteger:self.levelSubsribeID forKey:@"level_subscribe_id"];
    [aCoder encodeInteger:self.tempSubsribeID forKey:@"temp_subscribe_id"];
}

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self)
    {
        self.did = [aDecoder decodeObjectForKey:@"did"];
        self.macAddress = [aDecoder decodeObjectForKey:@"macAddress"];
        self.password = [aDecoder decodeObjectForKey:@"password"];
        self.ip = [aDecoder decodeObjectForKey:@"ip"];
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.isLock = [aDecoder decodeBoolForKey:@"isLock"];
        self.ID = [aDecoder decodeObjectForKey:@"id"];
        self.is_temperature_on = [aDecoder decodeBoolForKey:@"is_temperature_on"];
        self.is_level_on = [aDecoder decodeBoolForKey:@"is_level_on"];
        self.is_load_on = [aDecoder decodeBoolForKey:@"is_load_on"];
        self.loadSubsribeID = (int)[aDecoder decodeIntegerForKey:@"load_subscribe_id"];
        self.levelSubsribeID = (int)[aDecoder decodeIntegerForKey:@"level_subscribe_id"];
        self.tempSubsribeID = (int)[aDecoder decodeIntegerForKey:@"temp_subscribe_id"];
        
    }
    return self;
}

@end
